import React, {Component} from 'react';

import {connect} from "react-redux";
import {hideAd} from "../../store/actionCreated";

class Ad extends Component {
    render() {
        return (
            <div>
                <h2>广告系统</h2>
                {
                    this.props.adList.map(item => {
                        return (
                            <ul key={item.id}>
                                <li>序号：{item.id}</li>
                                <li>标题：{item.title}</li>
                                <li>封面图： <img src={item.imgUrl} alt=""/></li>
                                <li>
                                    <button onClick={this.props.hideAd.bind(this, item.id)}>关闭
                                    </button>
                                </li>
                            </ul>
                        )
                    })
                }
            </div>
        );
    }
}

export default connect((state) => {
    return {
        adList: state.adData,
    }
}, {hideAd})(Ad);
